<{extend name="public/layout"}>
<{block name="content"}>
<div class="content-wrapper">
  <!-- Content Header (Page header) -->
  <section class="content-header">
    <div class="container-fluid">
      <div class="row mb-2">
        <div class="col-sm-6">
          <h1></h1>
        </div>
        <div class="col-sm-6">
          <ol class="breadcrumb float-sm-right">
            <li class="breadcrumb-item"><a href="<{:url('/admin/index/index')}>">首页</a></li>
            <li class="breadcrumb-item"><a href="#">插件管理</a></li>
            <li class="breadcrumb-item active">备份管理</li>
          </ol>
        </div>
      </div>
    </div><!-- /.container-fluid -->
  </section>

  <!-- Main content -->
  <section class="content">
    <div class="container-fluid">


      <div class="card">


        <div class="card-body">
          <span class="btn btn-success  " onclick="backup()"  title="新增备份">新增</span>
          <table id="my_table" class="table table-bordered table-striped">
            <thead>
            <tr>

              <th>文件名称</th>
              <th>文件大小</th>
              <th>备份时间</th>
              <th>操作</th>
            </tr>
            </thead>
            <tbody>
            <{if !empty($data)}>
            <{foreach $data as $item}>
            <tr>

              <td ><{$item.name}></td>
              <td>
                <{$item.size}>
              </td>
              <td>
                <{$item.add_time}>
              </td>


              <td>
                <a class="btn btn-primary btn-xs del-data bs-left-10"  href="<{:url('download',['name'=>$item.name])}>"   title="下载"><i class="fas fa-download"></i></a>

                <span class="btn btn-danger btn-xs del-data bs-left-10" onclick="del(this)" data-name="<{$item.name}>" title="删除"><i class="fas fa-trash"></i></span>
              </td>

            </tr>
            <{/foreach}>
            <{/if}>
            </tbody>
            <tfoot>


            </tfoot>
          </table>
        </div>
        <div class="card-footer">
          <{$page?$page->render():''}>
        </div>
        <!-- /.card-body -->
      </div>
    </div>



  </section>
  <!-- /.content -->
</div>

<{/block}>
<{block name="script"}>
<script>
  function del(obj){
    var name = $(obj).data('name')

    layer.confirm('确定要删除吗，不可恢复哦',{title:0},function () {
      sendData("<{:url('del')}>",{name:name},function (res) {
        if(res.code==0){
          $(obj).parent('td').parent('tr').remove();
        }
      })
    })
  }

  function backup(){
    sendData("<{:url('backup')}>",{},function (res) {
      if(res.code==0){
        location.replace(location.href)
      }
    })
  }


  $(function () {
    $("#my_table").DataTable({
      "ordering": false,//禁用排序
      "responsive": true,
      "lengthChange": false,
      "autoWidth": false,
      //"buttons": ["copy", "csv", "excel", "pdf", "print", "colvis"],
      // "pageLength": 10,         //初始化显示几条数据
      //serverSide: true, // use local process instead of server
      bFilter: false, // show top right search input box.
      bPaginate: false,//是否开启分页
      //iDisplayLength: 10, //默认显示的记录数
      bInfo: false,//是否显示页脚信息，DataTables插件左下角显示记录数
    }).buttons().container().appendTo('#my_table_wrapper .col-md-6:eq(0)');

  });
</script>

<{/block}>


